<include file="./Application/Home/View/Public/Base/_meta.html"/>
<block name="body">
    <style>
        .mk-hasbtn{
            margin-top: 0px;
        }

        .table th,.table td{
            font-size: 13px;
        }

        .table th{
            background: #E0EAF6 !important;
        }

        .mk-row{
            margin-bottom: 20px;
            padding: 0px 4%;
        }

        .mk-row label{
            display: block;
            margin-bottom: 10px;
        }

        .mk-row label span{
            color: red;
        }

        .mk-submit{
            text-align: center;
        }
    </style>
    <article class="cl pd-20">
        <div class="mt-20 mk-hasbtn">
            <div class="mk-row">
                <label><span>*</span>用户国标ID:</label>
                <input type="text" class="input-text radius size-M" name="gbid">
            </div>
            <div class="mk-row">
                <label><span>*</span>用户名:</label>
                <input type="text" class="input-text radius size-M" name="userName">
            </div>
            <div class="mk-row">
                <label><span>*</span>用户密码:</label>
                <input type="password" class="input-text radius size-M" name="passWord">
            </div>
            <div class="mk-row">
                <label><span>*</span>确认密码:</label>
                <input type="password" class="input-text radius size-M" name="passWordCheck">
            </div>
            <div class="mk-submit">
                <button id="mkJsSubmit" class="btn btn-primary radius">提交</button>
            </div>
        </div>
    </article>
    <include file="./Application/Home/View/Public/Base/_footer.html"/>
    <script>
        $("#mkJsSubmit").click(function(){
            var usergbid = $("input[name='gbid']").val();
            var username = $("input[name='userName']").val();
            var password = $("input[name='passWord']").val();
            var passWordCheck = $("input[name='passWordCheck']").val();
            if(!usergbid){
                layer.msg('用户国标ID不能为空', {
                    icon: 2,
                    time: 1000
                });
                return;
            }else if(!username){
                layer.msg('用户名不能为空', {
                    icon: 2,
                    time: 1000
                });
                return;
            }else if(!password){
                layer.msg('用户密码不能为空', {
                    icon: 2,
                    time: 1000
                });
                return;
            }
            if(password != passWordCheck){
                layer.msg('两次密码输入不一致', {
                    icon: 2,
                    time: 1000
                });
                return;
            }
            var url = "{:U('Home/SipUser/addUser_post')}";
            var data = {
                usergbid:usergbid,
                username:username,
                password:password
            }
            $.post(url,data,function(res){
                if(res === 0){
                    layer.msg('添加成功', {
                        icon: 1,
                        time: 1000
                    });
                    setTimeout(function(){
                        parent.layer.closeAll();
                        parent.location.reload();
                    },1000);
                }else {
                    layer.msg('添加失败，请重试', {
                        icon: 2,
                        time: 1000
                    });
                }
            })
        })
    </script>
</block>